package com.owo.springboot.service;


import com.owo.springboot.dto.UserProfileResponse;
import com.owo.springboot.repository.UserRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
@RequiredArgsConstructor
public class ProfileService {

    private final UserRepository userRepository;

    public Optional<UserProfileResponse> getProfileByUsername(String username) {
        return userRepository.findByUsername(username)
                .map(user -> UserProfileResponse.builder()
                        .id(user.getId())
                        .username(user.getUsername())
                        .email(user.getEmail())
                        .build());
    }
}